<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" pageEncoding="utf-8"%>


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<link rel="stylesheet"
	href="<c:url value="/resources/lib/bootstrap-3.3.5/css/bootstrap.min.css"/>" />
	<link href="/resources/lib/font-awesome-4.4.0/css/font-awesome.min.css"
	rel="stylesheet" type="text/css" />
<link rel="stylesheet"
	href="<c:url value="/resources/css/common.css"/>" />
	
<link href="/resources/css/header.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet"
	href="<c:url value="/resources/css/dataAdaptor/excelType.css"/>" />
	
<script src="<c:url value="/resources/lib/jquery-2.1.4.min.js" />"
	type="text/javascript"></script>
<script
	src="<c:url value="/resources/lib/bootstrap-3.3.5/js/bootstrap.min.js" />"
	type="text/javascript"></script>
	
<script
	src="<c:url value="/resources/lib/angular-1.4.7/angular.min.js"/>"
	type="text/javascript">
	
</script>
<script
	src="<c:url value="/resources/lib/ui-bootstrap-tpls-0.13.4.min.js"/>"
	type="text/javascript">
	
</script>

<script src="<c:url value="/resources/js/dataAdaptor/csvType.js" />"
	type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSV data adaptor</title>
</head>
<body ng-app="conversionTool">

	<ng-include src="'/resources/viewPart/nav.html'" >
	
	</ng-include>

	<header>
	   <div class="head-line">
		<h3 class="head-title">View Data Adaptor</h3>
		</div>
	</header>

	<section class="container" ng-controller="csvTypeAdaptorCtrl as csv">
		<form role="form" name="csv.from" ng-submit="upload()"
			enctype="multipart/form-data" method="post" action="${updateURL}" class="form-horizontal">


			<!-- initial process -->
			<div ng-init="isEdit=${isEdit}"></div>
			<div ng-init="currentDataAdaptor.id='${dataAdaptor.id}'"></div>
			<div ng-init="isDefault=${isDefault}"></div>


			<div>
				<input type="hidden" ng-model="currentDataAdaptor.id" name="id"
					value="${dataAdaptor.id}" />
			</div>
			<!-- add view lable -->
              <div class="form-group text-center">
                <div class="col-xs-offset-1 text-left">
                <label>View Detail:<span>
                {{currentDataAdaptor.adaptorName}}
                </span> 
                </label> 
                 </div>
                 </div>

			<div class="form-group text-center form-line">
                  <div class="col-xs-4 text-right">
				<label for="adaptorName">Adaptor Name</label>
				</div>
				
				<div class="col-xs-8"> 
				 <input type="text"
					class="form-control" id="adaptorName" name="adaptorName"
					placeholder="please enter adaptor name"
					ng-init="currentDataAdaptor.adaptorName='${dataAdaptor.adaptorName}'"
					ng-model="currentDataAdaptor.adaptorName" ng-disabled="!isEdit" />
			</div>
			</div>


			<div class="form-group text-center form-line">
			<div class="col-xs-4 text-right">
				<label for="adaptorName">Description</label>
				
				</div>
				<div class="col-xs-8">
				<textarea id="description" class="form-control" name="description"
					ng-disabled="!isEdit" ng-model="currentDataAdaptor.description"
					ng-init="currentDataAdaptor.description='${dataAdaptor.description}'"> </textarea>
			</div>
			</div>

			<div id="CSVDetail">
			<div class="form-group text-center form-line">
			<div class="col-xs-4 text-right">
				<lable class="setting-lable">CSV Detail Setting</lable>
           </div>
           </div>
                  <div class="form-group text-center form-line">
                  <div class="col-xs-4 text-right"></div>
                  <div class="col-xs-8">
				  <div ng-show="!isEdit">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th>sequence</th>
								<th>column</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${dataAdaptor.header}" var="entry"
								varStatus="status">
								<tr>
									<td>${status.count}</td>
									<td>${entry}</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>

				</div>
				</div>
				</div>

				<div class="form-group text-center form-line">
                           <div class="col-xs-4 text-right">
					<label for="isDefault">Split default <input
						type="checkbox" ng-model="isDefault" ng-true-value="true"
						ng-false-value="false" ng-click="defaultClick()" /></label>
					</div>
					
					<!--<input type="checkbox" ng-model="isDefault" ng-true-value="true"  ng-false-value="false" ng-click="defaultClick()" />-->

				</div>

				<div ng-show="!isDefault">

					<div class="form-group text-center form-line">
                         <div class="col-xs-4 text-right">
						<label for="lineSeparator">Line sepatator</label> 
						</div>
						<div class="col-xs-8">
						<input
							type="text" class="form-control" id="lineSeparator"
							name="lineSeparator" ng-model="csvDataType.lineSeparator"
							ng-maxlength="1"
							ng-init="csvDataType.lineSeparator='${csvDataType.lineSeparator}'"
							ng-disabled="!isEdit" />
							</div>
					</div>

					<div class="form-group text-center form-line">
					<div class="col-xs-4 text-right">
						<label for="columnSepatator">Column sepatator</label> 
						</div>
						<div class="col-xs-8">
						
						<input
							type="text" class="form-control" id="columnSepatator"
							ng-model="csvDataType.columnSepatator" name="columnSepatator"
							ng-init="csvDataType.columnSepatator='${csvDataType.columnSepatator}'"
							ng-disabled="!isEdit" ng-maxlength="1" />
							</div>
					</div>
				</div>
			</div>

			<div class="form-group text-center form-line" ng-show="isEdit">
			<div class="col-xs-4 text-right">
				<label for="csvTemplateFile">Upload Csv Template File </label>
				</div>
				
				<div class="col-xs-8"> 
				<input type="file" class="form-control" name="file" id="csvTemplateFile" ng-disabled="!isEdit" ng-model="uploadFile" single accept=".csv" />
					</div>
			</div>

			<div class="form-group text-right form-right">
			<input type="button" value="Edit" class="btn btn-primary" ng-disabled="isEdit" ng-click="edit()" /> 
			<input type="submit" value="Save" ng-disabled="!isEdit" class="btn btn-primary" /> 
			<input type="button" value="Filter" class="btn btn-primary" ng-disabled="isEdit" ng-click="filter()" /> 
			<input type="button" value="Formula" class="btn btn-primary" ng-disabled="isEdit" ng-click="formula()" />
			</div>
            <div class="form-group text-right form-right">
			<div class="control-group error">
					<span class="help-inline">{{msg}}</span>
				
			</div>
			</div>

		</form>
	</section>


</body>
</html>
